package com.Tools
{
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class ScreenTrace extends Sprite
	{
		private static var st:ScreenTrace;
		
		/**
		 * 初始化trace  用于将trace添加到舞台
		 * @return
		 */
		public static function getTrace():ScreenTrace {
			if (st==null) {
				st = new ScreenTrace();
			}
			return st;
		}
		
		/**
		 * 向显示列表中添加一个trace
		 * @param	s
		 */
		public static function trace(s:*):void {
			ScreenTrace.getTrace().AddTrace(String(s));
		}
		
		
		
		private var list:Vector.<TextField>;
		
		public function ScreenTrace()
		{
			super();
			
			list = new Vector.<TextField>();
		}
		
		//------------------------------------------
		
		
		private function AddTrace(s:String):void {
			var temp:TextField = new TextField();
			temp.text = s;
			if (list.length == 10) {
				this.removeChild(list[0]);
				list.shift();
			}
			list.push(temp);
			this.addChild(temp);
			for (var i:int=0;i<list.length;i++){
				list[i].y = 20 * (list.length-i);
			}
		}
	}
}